<!DOCTYPE html>
<html>
<head>
    <title>欢迎登录</title>
    <link rel="stylesheet" type="text/css" href="/bootstrap/css/bootstrap.min.css">
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script src="/js/md5.js"></script>
</head>
<body>
<div class="container" style="margin-top:180px; ">

    <div class="col-md-6 col-md-offset-3">
        <div class="panel panel-primary">
            <div class="panel-heading">登录学生管理系统</div>
            <div class="panel-body">
                <form class="form-horizontal">
                    <div class="form-group">
                        <label for="uname" class="col-sm-2 control-label">用户名</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="username" id="username" placeholder="请输入用户名">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="pwd" class="col-sm-2 control-label">密码</label>
                        <div class="col-sm-10">
                            <input type="password" class="form-control" name="password" id="password" placeholder="请输入密码">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            <button onclick="login()" class="btn btn-default">登录</button>
                            <input  onclick="register();" type="button"  value="注册" class="btn btn-danger">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    function register() {
        window.location="/account/register";
    }

    function login() {
        var username=$("#username").val();
        var password=$("#password").val();
        password=$.md5(password);

        $.ajax({
            type:"post",
            url:"/account/login",
            data:{username:username,password:password},
            success:function (data) {
                window.location="/studentmanager/list";
            },
            error:function (error) {
                console.log(error);
            }
        })

    }



</script>
</html>
